<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="my.market.jdbc.dataClass.Goods" %>
<%@ page import="java.util.List" %>

<%List<Goods> goods = (List<Goods>)request.getAttribute("goods"); %>
<html>
<head>
<script type="text/javascript">
function click_func(obj, myid){
	//点击时，如果取得的值和搜索框默认value值相同，则将搜索框清空
	if (document.getElementById(myid).value == document.getElementById(myid).defaultValue){
	  document.getElementById(myid).value = '';
	  obj.style.color='#000';
	}
}
//鼠标不聚焦在搜索框时执行
function blur_func(obj, myid){
	//鼠标失焦时，如果搜索框没有输入值，则用搜索框的默认value值填充
	if (document.getElementById(myid).value == ''){
	 document.getElementById(myid).value = document.getElementById(myid).defaultValue;
	 obj.style.color='#666';
 }
}
</script>
</head>
<body>
<p align="left">商品管理<br/><br/><br/></p>
<table>
	<tr>
		<td align="center" width="24%">商品编号</td>
		<td align="center" width="18%">商品名称</td>
		<td align="center" width="9%">商品价格</td>
		<td align="center" width="9%">商品销量</td>
		<td width="8%" align="center">商品类别</td>
		<td width="8%" align="center">编辑</td>
		<td width="8%" align="center">删除</td>
	</tr>
	<c:forEach var="good" items="<%=goods %>" >
		<tr onmouseover="this.style.backgroundColor = 'white'"
			onmouseout="this.style.backgroundColor = '#F5FAFE';">
			<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="200">${good.getId() }</td>
			<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="18%">${good.getName() }</td>
			<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="8%">${good.getPrice() }</td>
			<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="8%">${good.getSalesnum() }</td>
			<td style="CURSOR: hand; HEIGHT: 22px" align="center">${good.getType()}</td>
			<td align="center" style="HEIGHT: 22px" width="7%">
				<a href="${pageContext.request.contextPath}/back_end/display/updateGood.jsp?id=${good.getId() }">修改</a>
			</td>
			<td align="center" style="HEIGHT: 22px" width="7%">
				<a href="${pageContext.request.contextPath}/deleteGood?id=${good.getId() }">删除</a>
			</td>
		</tr>
	</c:forEach>
</table>
<form action="${pageContext.request.contextPath}/searchGoods" method="post" >
<table>
	<tr>
		<td>
			<a href="${pageContext.request.contextPath}/back_end/display/addGood.jsp"><button type="button">添加</button></a>
		</td>
	</tr>
	<tr>
		<td><a href="${pageContext.request.contextPath}/back_end/display/orders.jsp"><button type="button">返回</button></a></td>
	</tr>
	<tr>
		<td>
			<input type="text" name="g_name" id="g_name" value="请输入商品名称" 
					onmouseover="this.focus();"
					onclick="click_func(this, 'g_name');"
					onBlur="blur_func(this, 'g_name');"/>
			<input type="submit" value="查询" />
		</td>
	</tr>
</table>
</form>
</body>
</html>